
var PAHO_MQTT_QOS_ARRAY = [
    ['QOS0', '0'],
    ['QOS1', '1'],
    ['QOS2', '2']
];


Blockly.Blocks['paho_mqtt_package'] = {
    init: function() {
        this.appendDummyInput()
            .appendField('导入 paho.mqtt.client 包为 mqtt');
        this.setOutput(false);
        this.setColour('%{BKY_PAHO_MQTT_HUE}');
        this.setNextStatement(true);
        this.setPreviousStatement(true);
        this.setTooltip('加载paho.mqtt.client包');
        this.setHelpUrl('');
    }
};

// Blockly.defineBlocksWithJsonArray([
//     {
//         "type": "paho_mqtt_init",
//         "message0": "",
//         "output": "PAHO.MQTT.CLIENT",
//         "helpUrl": "",
//         "colour": 275,
//         "tooltip": "创建 MQTT 客户端",
//         "mutator": "paho_mqtt_init_mutator"
//     }
// ]);


Blockly.Blocks['paho_mqtt_init'] = {
    init: function() {
        this.appendValueInput("CLIENT")
            .setCheck("String")
            .appendField('创建 MQTT 客户端 ID ');
        this.appendValueInput("SESSION")
            .appendField('是否清除会话 ')
            .setCheck('Boolean')
            .setAlign(Blockly.ALIGN_RIGHT);
        this.setOutput(true, 'PAHO.MQTT.CLIENT');
        this.setColour('%{BKY_PAHO_MQTT_HUE}');
        this.setTooltip('创建 MQTT 客户端');
        this.setHelpUrl('');
    }
};

Blockly.Blocks['paho_mqtt_username_password'] = {
    init: function() {
        this.appendValueInput('CLIENT')
            .appendField('设置 客户端 ');
        this.appendValueInput('USERNAME')
            .setCheck('String')
            .appendField('用户名 ')
            .setAlign(Blockly.ALIGN_RIGHT);
        this.appendValueInput('PASSWORD')
            .setCheck('String')
            .appendField('密码 ')
            .setAlign(Blockly.ALIGN_RIGHT);
        this.setOutput(false);
        this.setColour('%{BKY_PAHO_MQTT_HUE}');
        this.setNextStatement(true);
        this.setPreviousStatement(true);
        this.setTooltip('设置 MQTT 客户端登录用户名和密码');
        this.setHelpUrl('');
    }
};

Blockly.Blocks['paho_mqtt_on_connect'] = {
    init: function() {
        this.appendValueInput('CLIENT')
            .setCheck('PAHO.MQTT.CLIENT')
            .appendField('设置 连接服务器回调 客户端 ');
        this.appendStatementInput('SUCCESS_STATEMENT')
            .appendField('成功 ')
            .setAlign(Blockly.ALIGN_RIGHT);
        this.appendStatementInput('FAILURE_STATEMENT')
            .appendField('失败 ')
            .setAlign(Blockly.ALIGN_RIGHT);
        this.setOutput(false);
        this.setColour('%{BKY_PAHO_MQTT_HUE}');
        this.setNextStatement(true);
        this.setPreviousStatement(true);
        this.setTooltip('当连接到 MQTT 服务器时执行的操作');
        this.setHelpUrl('');
    }
};

Blockly.Blocks['paho_mqtt_on_message'] = {
    init: function() {
        this.appendValueInput('CLIENT')
            .setCheck('PAHO.MQTT.CLIENT')
            .appendField('设置 消息到达回调 客户端 ');
        this.appendStatementInput('STATEMENT')
            .appendField('执行 ')
            .setAlign(Blockly.ALIGN_RIGHT);
        this.setOutput(false);
        this.setColour('%{BKY_PAHO_MQTT_HUE}');
        this.setNextStatement(true);
        this.setPreviousStatement(true);
        this.setTooltip('当接收到 MQTT 服务器发送过来的消息时执行的操作');
        this.setHelpUrl('');
    }
};

Blockly.Blocks['paho_mqtt_qos'] = {
    init: function() {
        this.appendDummyInput()
            .appendField(new Blockly.FieldDropdown(PAHO_MQTT_QOS_ARRAY), 'QOS');
        this.setOutput(true, 'Number');
        this.setColour('%{BKY_PAHO_MQTT_HUE}');
        this.setTooltip('服务质量等级');
        this.setHelpUrl('');
    }
};

Blockly.Blocks['paho_mqtt_subscribe'] = {
    init: function() {
        this.appendValueInput("CLIENT")
            .setCheck('PAHO.MQTT.CLIENT')
            .appendField('订阅 消息 客户端 ');
        this.appendValueInput('TOPIC')
            .setCheck('String')
            .appendField('主题 ')
            .setAlign(Blockly.ALIGN_RIGHT);
        this.appendValueInput('QOS')
            .appendField('服务质量等级 ')
            .setAlign(Blockly.ALIGN_RIGHT);
        this.setOutput(false);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setColour('%{BKY_PAHO_MQTT_HUE}');
        this.setTooltip('订阅消息');
        this.setHelpUrl('');
    }
};

Blockly.Blocks['paho_mqtt_publish'] = {
    init: function() {
        this.appendValueInput('CLIENT')
            .setCheck('PAHO.MQTT.CLIENT')
            .appendField('发布 消息 客户端 ');
        this.appendValueInput('TOPIC')
            .setCheck('String')
            .appendField('主题 ')
            .setAlign(Blockly.ALIGN_RIGHT);
        this.appendValueInput('QOS')
            .setCheck('Number')
            .appendField('服务质量等级 ')
            .setAlign(Blockly.ALIGN_RIGHT);
        this.appendValueInput('PAYLOAD')
            .setCheck('String')
            .appendField('内容 ')
            .setAlign(Blockly.ALIGN_RIGHT);
        this.setOutput(false);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setColour('%{BKY_PAHO_MQTT_HUE}');
        this.setTooltip('订阅消息');
        this.setHelpUrl('');
    }
};

Blockly.Blocks['paho_mqtt_message_topic'] = {
    init: function() {
        this.appendDummyInput()
            .appendField('接收 消息主题')
        this.setOutput(true, 'String');
        this.setColour('%{BKY_PAHO_MQTT_HUE}');
        this.setTooltip('获得 MQTT 服务器发送过来的消息主题');
        this.setHelpUrl('');
    }
};

Blockly.Blocks['paho_mqtt_message_payload'] = {
    init: function() {
        this.appendDummyInput()
            .appendField('接收 消息内容')
        this.setOutput(true, 'String');
        this.setColour('%{BKY_PAHO_MQTT_HUE}');
        this.setTooltip('获得 MQTT 服务器发送过来的消息内容');
        this.setHelpUrl('');
    }
};

Blockly.Blocks['paho_mqtt_message_qos'] = {
    init: function() {
        this.appendDummyInput()
            .appendField('接收 消息服务质量')
        this.setOutput(true, 'Number');
        this.setColour('%{BKY_PAHO_MQTT_HUE}');
        this.setTooltip('获得 MQTT 服务器发送过来的消息服务质量等级');
        this.setHelpUrl('');
    }
};

Blockly.Blocks['paho_mqtt_connect'] = {
    init: function() {
        this.appendValueInput('CLIENT')
            .setCheck('PAHO.MQTT.CLIENT')
            .appendField('连接 MQTT服务器 客户端 ');
        this.appendValueInput('SERVER')
            .setCheck('String')
            .appendField('服务器地址 ')
            .setAlign(Blockly.ALIGN_RIGHT);
        this.appendValueInput('PORT')
            .setCheck('Number')
            .appendField('端口号 ')
            .setAlign(Blockly.ALIGN_RIGHT);
        this.appendValueInput('KEEP_ALIVE')
            .setCheck('Number')
            .appendField('探活 ')
            .setAlign(Blockly.ALIGN_RIGHT);
        this.appendDummyInput()
            .appendField('阻塞主线程 ')
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(new Blockly.FieldCheckbox(false), 'BLOCKED');
            // .appendField(new Blockly.FieldCheckbox(false, function (newValue) {
            //     if(newValue=='TRUE'){
            //         var block = this.getSourceBlock();
            //         block.setNextStatement(false);
            //     }else{
            //         var block = this.getSourceBlock();
            //         block.setNextStatement(true);
            //     }
            //
            //     return newValue;
            // }), 'BLOCKED');
        this.setInputsInline(false);
        this.setOutput(false);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setColour('%{BKY_PAHO_MQTT_HUE}');
        this.setTooltip('连接 MQTT 服务器');
        this.setHelpUrl('');
    }
};

Blockly.Blocks['paho_mqtt_disconnect'] = {
    init: function() {
        this.appendValueInput('CLIENT')
            .setCheck('PAHO.MQTT.CLIENT')
            .appendField('断开 与MQTT服务器的连接 客户端 ');
        this.setInputsInline(false);
        this.setOutput(false);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setColour('%{BKY_PAHO_MQTT_HUE}');
        this.setTooltip('调用disconnect()断开与服务器的连接');
        this.setHelpUrl('');
    }
};

Blockly.Blocks['paho_mqtt_loop_stop'] = {
    init: function() {
        this.appendValueInput('CLIENT')
            .setCheck('PAHO.MQTT.CLIENT')
            .appendField('停止 MQTT网络循环 客户端 ');
        this.setInputsInline(false);
        this.setOutput(false);
        this.setPreviousStatement(true);
        this.setNextStatement(true);
        this.setColour('%{BKY_PAHO_MQTT_HUE}');
        this.setTooltip('调用loop_stop()结束网络循环');
        this.setHelpUrl('');
    }
};


// Blockly.Blocks['paho_mqtt_on_connect'] = {
//     init: function() {
//         this.appendValueInput('CLIENT')
//             .setCheck('PAHO.MQTT.CLIENT')
//             .appendField('当连接到服务器时 客户端 ');
//         this.appendStatementInput('STATEMENT')
//             .appendField('执行 ')
//             .setAlign(Blockly.ALIGN_RIGHT);
//         this.setOutput(false);
//         this.setColour('%{BKY_PAHO_MQTT_HUE}');
//         this.setMutator(new Blockly.Mutator(['paho_mqtt_subscribe_mutator']));
//         this.setNextStatement(true);
//         this.setPreviousStatement(true);
//         this.setTooltip('当连接到 MQTT 服务器时执行的操作');
//         this.setHelpUrl('');
//     },
//     pahoMqttSubscribeMutatorCount_: 0,
//     /**
//      * Create XML to represent the number of else-if and else inputs.
//      * @return {Element} XML storage element.
//      * @this {Blockly.Block}
//      */
//     mutationToDom: function() {
//         if (!this.elseifCount_ && !this.elseCount_) {
//             return null;
//         }
//         var container = Blockly.utils.xml.createElement('mutation');
//         if (this.elseifCount_) {
//             container.setAttribute('elseif', this.elseifCount_);
//         }
//         if (this.elseCount_) {
//             container.setAttribute('else', 1);
//         }
//         return container;
//     },
//     /**
//      * Parse XML to restore the else-if and else inputs.
//      * @param {!Element} xmlElement XML storage element.
//      * @this {Blockly.Block}
//      */
//     domToMutation: function(xmlElement) {
//         this.elseifCount_ = parseInt(xmlElement.getAttribute('elseif'), 10) || 0;
//         this.elseCount_ = parseInt(xmlElement.getAttribute('else'), 10) || 0;
//         this.rebuildShape_();
//     },
//     /**
//      * Populate the mutator's dialog with this block's components.
//      * @param {!Blockly.Workspace} workspace Mutator's workspace.
//      * @return {!Blockly.Block} Root block in mutator.
//      * @this {Blockly.Block}
//      */
//     decompose: function(workspace) {
//         var containerBlock = workspace.newBlock('paho_mqtt_on_connect_start_mutator');
//         containerBlock.initSvg();
//         var connection = containerBlock.nextConnection;
//         for (var i = 1; i <= this.pahoMqttSubscribeMutatorCount_; i++) {
//             var subscribeBlock = workspace.newBlock('paho_mqtt_subscribe_mutator');
//             subscribeBlock.initSvg();
//             connection.connect(subscribeBlock.previousConnection);
//             connection = subscribeBlock.nextConnection;
//         }
//         return containerBlock;
//     },
//     /**
//      * Reconfigure this block based on the mutator dialog's components.
//      * @param {!Blockly.Block} containerBlock Root block in mutator.
//      * @this {Blockly.Block}
//      */
//     compose: function(containerBlock) {
//         var clauseBlock = containerBlock.nextConnection.targetBlock();
//         // Count number of inputs.
//         this.pahoMqttSubscribeMutatorCount_ = 0;
//         var statementConnections = [null];
//         while (clauseBlock) {
//             switch (clauseBlock.type) {
//                 case 'paho_mqtt_subscribe_mutator':
//                     this.pahoMqttSubscribeMutatorCount_++;
//                     statementConnections.push(clauseBlock.statementConnection_);
//                     break;
//                 default:
//                     throw TypeError('Unknown block type: ' + clauseBlock.type);
//             }
//             clauseBlock = clauseBlock.nextConnection &&
//                 clauseBlock.nextConnection.targetBlock();
//         }
//         this.updateShape_();
//         // Reconnect any child blocks.
//         this.reconnectChildBlocks_(statementConnections);
//     },
//     /**
//      * Store pointers to any connected child blocks.
//      * @param {!Blockly.Block} containerBlock Root block in mutator.
//      * @this {Blockly.Block}
//      */
//     saveConnections: function(containerBlock) {
//         var clauseBlock = containerBlock.nextConnection.targetBlock();
//         var i = 1;
//         while (clauseBlock) {
//             switch (clauseBlock.type) {
//                 case 'paho_mqtt_subscribe_mutator':
//                     var inputSubscribe = this.getInput('SUBSCRIBE' + i);
//                     clauseBlock.statementConnection_ = inputSubscribe &&
//                         inputSubscribe.connection.targetConnection;
//                     i++;
//                     break;
//                 default:
//                     throw TypeError('Unknown block type: ' + clauseBlock.type);
//             }
//             clauseBlock = clauseBlock.nextConnection &&
//                 clauseBlock.nextConnection.targetBlock();
//         }
//     },
//     /**
//      * Reconstructs the block with all child blocks attached.
//      * @this {Blockly.Block}
//      */
//     rebuildShape_: function() {
//         var statementConnections = [null];
//
//         var i = 1;
//         while (this.getInput('SUBSCRIBE' + i)) {
//             var inputSubscribe = this.getInput('SUBSCRIBE' + i);
//             statementConnections.push(inputSubscribe.connection.targetConnection);
//             i++;
//         }
//         this.updateShape_();
//         this.reconnectChildBlocks_(statementConnections);
//     },
//     /**
//      * Modify this block to have the correct number of inputs.
//      * @this {Blockly.Block}
//      * @private
//      */
//     updateShape_: function() {
//         // // Delete everything.
//         var i = 1;
//         while (this.getInput('SUBSCRIBE' + i)) {
//             this.removeInput('SUBSCRIBE' + i);
//             i++;
//         }
//
//         // var clauseBlock = containerBlock.nextConnection.targetBlock();
//         // var clauseBlock = this.nextConnection.targetBlock();
//         var connection = this.getFirstStatementConnection();
//         var i = 1;
//         // Rebuild block.
//         for (i = 1; i <= this.pahoMqttSubscribeMutatorCount_; i++) {
//             console.log('here');
//             var block =  this.workspace.newBlock('paho_mqtt_subscribe');
//             block.initSvg();
//             console.log(block);
//
//             connection.connect(block.previousConnection);
//             connection = block.nextConnection;
//         }
//         //
//         //
//         //
//         //
//         //
//         //
//         // var containerBlock = workspace.newBlock('paho_mqtt_on_connect_start_mutator');
//         // containerBlock.initSvg();
//         // var connection = containerBlock.nextConnection;
//         // for (var i = 1; i <= this.pahoMqttSubscribeMutatorCount_; i++) {
//         //     var subscribeBlock = workspace.newBlock('paho_mqtt_subscribe_mutator');
//         //     subscribeBlock.initSvg();
//         //     connection.connect(subscribeBlock.previousConnection);
//         //     connection = subscribeBlock.nextConnection;
//         // }
//         // return containerBlock;
//
//
//
//         // while (clauseBlock) {
//         //     switch (clauseBlock.type) {
//         //         case 'paho_mqtt_subscribe_mutator':
//         //             var inputSubscribe = this.getInput('SUBSCRIBE' + i);
//         //             clauseBlock.statementConnection_ = inputSubscribe &&
//         //                 inputSubscribe.connection.targetConnection;
//         //             i++;
//         //             break;
//         //         default:
//         //             throw TypeError('Unknown block type: ' + clauseBlock.type);
//         //     }
//         //     clauseBlock = clauseBlock.nextConnection &&
//         //         clauseBlock.nextConnection.targetBlock();
//         // }
//
//
//
//
//
//
//         // // Rebuild block.
//         // for (i = 1; i <= this.pahoMqttSubscribeMutatorCount_; i++) {
//         //     this.appendStatementInput('SUBSCRIBE' + i)
//         //         .appendField('订阅消息主题000');
//         // }
//     },
//     /**
//      * Reconnects child blocks.
//      * @param {!Array.<?Blockly.RenderedConnection>} valueConnections List of
//      * value connections for 'if' input.
//      * @param {!Array.<?Blockly.RenderedConnection>} statementConnections List of
//      * statement connections for 'do' input.
//      * @param {?Blockly.RenderedConnection} elseStatementConnection Statement
//      * connection for else input.
//      * @this {Blockly.Block}
//      */
//     reconnectChildBlocks_: function(statementConnections) {
//         for (var i = 1; i <= this.pahoMqttSubscribeMutatorCount_; i++) {
//             Blockly.Mutator.reconnect(statementConnections[i], this, 'SUBSCRIBE' + i);
//         }
//     }
// };
//
// Blockly.Blocks['paho_mqtt_on_message'] = {
//     init: function() {
//         this.appendValueInput('CLIENT')
//             .setCheck('PAHO.MQTT.CLIENT')
//             .appendField('当有消息到达时 客户端 ');
//         this.appendStatementInput('STATEMENT')
//             .appendField('执行 ')
//             .setAlign(Blockly.ALIGN_RIGHT);
//         this.setOutput(false);
//         this.setColour('%{BKY_PAHO_MQTT_HUE}');
//         this.setNextStatement(true);
//         this.setPreviousStatement(true);
//         this.setTooltip('当接收到 MQTT 服务器发送过来的消息时执行的操作');
//         this.setHelpUrl('');
//     }
// };
//
// Blockly.Blocks['paho_mqtt_qos'] = {
//     init: function() {
//         this.appendDummyInput()
//             .appendField('服务质量等级 ')
//             .appendField(new Blockly.FieldDropdown(PAHO_MQTT_QOS_ARRAY), 'QOS');
//         this.setOutput(true, 'Number');
//         this.setColour('%{BKY_PAHO_MQTT_HUE}');
//         this.setTooltip('服务质量等级');
//         this.setHelpUrl('');
//     }
// };
//
// Blockly.Blocks['paho_mqtt_subscribe'] = {
//     init: function() {
//         this.appendValueInput('TOPIC')
//             .setCheck('String')
//             .appendField('订阅消息 主题 ');
//         this.appendDummyInput()
//             .appendField('等级 ')
//             .appendField(new Blockly.FieldDropdown(PAHO_MQTT_QOS_ARRAY), 'QOS')
//             .setAlign(Blockly.ALIGN_RIGHT);
//         this.setInputsInline(true);
//         this.setOutput(false);
//         this.setPreviousStatement(true);
//         this.setNextStatement(true);
//         this.setColour('%{BKY_PAHO_MQTT_HUE}');
//         this.setTooltip('订阅消息');
//         this.setHelpUrl('');
//     }
// };
//
//
//
//
//
// // 下面开始时Mutator
// Blockly.Blocks['paho_mqtt_on_connect_start_mutator'] = {
//     init: function() {
//         this.appendDummyInput()
//             .appendField('连接到 MQTT 服务器后');
//         this.setOutput(false);
//         this.setPreviousStatement(false);
//         this.setNextStatement(true);
//         this.setColour('%{BKY_PAHO_MQTT_HUE}');
//         this.setTooltip('连接到 MQTT 服务器后');
//         this.setHelpUrl('');
//     }
// };
//
// Blockly.Blocks['paho_mqtt_subscribe_mutator'] = {
//     init: function() {
//         this.appendDummyInput()
//             .appendField('订阅消息 ')
//         this.setInputsInline(true);
//         this.setOutput(false);
//         this.setPreviousStatement(true);
//         this.setNextStatement(true);
//         this.setColour('%{BKY_PAHO_MQTT_HUE}');
//         this.setTooltip('订阅消息');
//         this.setHelpUrl('');
//     }
// };

// Blockly.Constants.Mqtt = {};
// Blockly.Constants.Mqtt.PAHO_MQTT_INIT_MUTATOR_MIXIN = {
//     mutationToDom: function() {
//         var container = Blockly.utils.xml.createElement('mutation');
//         container.setAttribute('items', this.itemCount_);
//         return container;
//     },
//
//     domToMutation: function(xmlElement) {
//         this.itemCount_ = parseInt(xmlElement.getAttribute('items'), 10);
//         this.updateShape_();
//     },
//
//     decompose: function(workspace) {
//         var containerBlock = workspace.newBlock('text_create_join_container');
//         containerBlock.initSvg();
//         var connection = containerBlock.getInput('STACK').connection;
//         for (var i = 0; i < this.itemCount_; i++) {
//             var itemBlock = workspace.newBlock('text_create_join_item');
//             itemBlock.initSvg();
//             connection.connect(itemBlock.previousConnection);
//             connection = itemBlock.nextConnection;
//         }
//         return containerBlock;
//     },
//
//     compose: function(containerBlock) {
//         var itemBlock = containerBlock.getInputTargetBlock('STACK');
//         // Count number of inputs.
//         var connections = [];
//         while (itemBlock) {
//             connections.push(itemBlock.valueConnection_);
//             itemBlock = itemBlock.nextConnection &&
//                 itemBlock.nextConnection.targetBlock();
//         }
//         // Disconnect any children that don't belong.
//         for (var i = 0; i < this.itemCount_; i++) {
//             var connection = this.getInput('ADD' + i).connection.targetConnection;
//             if (connection && connections.indexOf(connection) == -1) {
//                 connection.disconnect();
//             }
//         }
//         this.itemCount_ = connections.length;
//         this.updateShape_();
//         // Reconnect any child blocks.
//         for (var i = 0; i < this.itemCount_; i++) {
//             Blockly.Mutator.reconnect(connections[i], this, 'ADD' + i);
//         }
//     },
//
//     saveConnections: function(containerBlock) {
//         var itemBlock = containerBlock.getInputTargetBlock('STACK');
//         var i = 0;
//         while (itemBlock) {
//             var input = this.getInput('ADD' + i);
//             itemBlock.valueConnection_ = input && input.connection.targetConnection;
//             i++;
//             itemBlock = itemBlock.nextConnection &&
//                 itemBlock.nextConnection.targetBlock();
//         }
//     },
//
//     updateShape_: function() {
//         if (this.itemCount_ && this.getInput('CLIENT_TITLE')) {
//             this.removeInput('CLIENT_TITLE');
//         } else if (!this.itemCount_ && !this.getInput('EMPTY')) {
//             this.appendDummyInput('EMPTY')
//                 .appendField('创建 MQTT 客户端');
//         }
//         // Add new inputs.
//         for (var i = 0; i < this.itemCount_; i++) {
//             if (!this.getInput('ADD' + i)) {
//                 var input = this.appendValueInput('ADD' + i);
//                 if (i == 0) {
//                     input.appendField('创建 MQTT 客户端');
//                 }
//             }
//         }
//         // Remove deleted inputs.
//         while (this.getInput('ADD' + i)) {
//             this.removeInput('ADD' + i);
//             i++;
//         }
//     }
// };
//
// Blockly.Constants.Mqtt.PAHO_MQTT_INIT_EXTENSION = function() {
//     // Add the quote mixin for the itemCount_ = 0 case.
//     this.mixin('fasdfasdfasdf');
//     // Initialize the mutator values.
//     this.itemCount_ = 0;
//     this.updateShape_();
//     // Configure the mutator UI.
//     this.setMutator(new Blockly.Mutator(['text_create_join_item']));
// };
//
// Blockly.Extensions.registerMutator('paho_mqtt_init_mutator',
//     Blockly.Constants.Mqtt.PAHO_MQTT_INIT_MUTATOR_MIXIN,
//     Blockly.Constants.Mqtt.PAHO_MQTT_INIT_EXTENSION);